package cn.edu.nuc.weiboclient;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import oauth.signpost.OAuth;
import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class SendMessage extends Activity{
	final String TAG = getClass().getName();
	private SharedPreferences prefs;
	Button sendButton = null;
	EditText edittext =null;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.send);
		prefs=PreferenceManager.getDefaultSharedPreferences(this); 
		
		edittext=(EditText)findViewById(R.id.sendEditTextId);
		sendButton=(Button) findViewById(R.id.sendSendButtonId);
		sendButton.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				String sendMessage = edittext.getText().toString();
				Map<String,String> map = new HashMap<String, String>();
				map.put("content", sendMessage);
				map.put("clientip", "127.0.0.1");
				map.put("format", "json");
				List<String> decodeNames = new ArrayList<String>();
				decodeNames.add("oauth_signature");
				WeiBoClient weiBoClient = new WeiBoClient(Constants.CONSUMER_KEY, Constants.CONSUMER_SECRET, prefs.getString(OAuth.OAUTH_TOKEN, ""), prefs.getString(OAuth.OAUTH_TOKEN_SECRET, ""));
				weiBoClient.doPost(Constants.WeiBoApi.ADD,map,decodeNames);
			}
		});
	}

}
